var oDiv;
var worker = null;
window.onload = function () {
    oDiv  = document.getElementById('number');

    document.getElementById('start').onclick = startWorker;
    document.getElementById('stop').onclick = function () {
        if(worker){
            worker.terminate();
            worker = null;
        }
    };

};
function startWorker () {
    if(worker){
       return;
    };
    worker = new Worker('count.js');
    worker.onmessage = function (e){
        oDiv.innerHTML = e.data;
        sessionStorage.num = e.data;
    }
}